package com.niuxiaofa.newlaw.Tools;

import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;
    int type = 0;

    int left=0;
    int top=0;
    public ItemOffsetDecoration(int itemOffset, int type) {
        mItemOffset = itemOffset;
       this.type=type;
    }

//    public ItemOffsetDecoration(Context context, int itemOffsetId) {
//        this(context.getResources().getDimensionPixelSize(itemOffsetId));
//    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
                               RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);

        //0横着 //1 竖着
        switch (type) {
            case  0:
                left=mItemOffset;
                break;

            case 1:
                top=mItemOffset;
                break;
        }
        outRect.set(left, top, left, top);
    }

}
